package level4Assessment;

import java.util.Date;

public class OverstayedParkingTransaction extends PrePaidParkingTransaction {

	private int expiryHour;
	private int expiryMin;
	private double totalCost;
	Date date = new Date();
	private int hourStaying;
	
	public OverstayedParkingTransaction(String registrationNumber,int arrivalHour,int arrivalMinute, int expiryHour, int expiryMinute, int hoursStaying) 
	{
		super(registrationNumber, arrivalHour, arrivalMinute, expiryHour, expiryMinute, hoursStaying);
		this.hourStaying = hoursStaying;
		this.expiryHour = expiryHour;

	}
	public double calculateTotalCost()
	{
		int overstayedTime = (int) (date.getHours() - ((expiryHour)));
		if(date.getDay() == 1 || date.getDay() == 7)
		{
			if(overstayedTime < 2)
			{
					totalCost = 4.40*0.9;
			}
			else if(overstayedTime < 6 && overstayedTime >=2)
			{
				totalCost = 7.40*0.9;
			}
			else if(overstayedTime < 24 && overstayedTime >=6)
			{
				totalCost = 12*0.9;
			}
		}else
		{
			if(overstayedTime < 2)
			{
					totalCost = 4.40*0.9;
			}
			else if(overstayedTime < 6 && overstayedTime >=2)
			{
				totalCost = 7.40*0.9;
			}
			else if(overstayedTime < 24 && overstayedTime >=6)
			{
				totalCost = 12*0.9;
			}
		}
		return Math.round(totalCost);
		
	}

}
